<?php
 include_once "../lib/DAL/QuaTrinhLopMon.php";

 class QuaTrinhLopMonBLL{
   
    function __construct(){
       
    }
    
    function __destruct(){
        
    }
    
    public function getQTLopMonInfo($madm_qtlm){
        $sql ="select * from tbl_quatrinhlopmon where ma_qtlm='".$madm_qtlm."'";
        $result =mysql_fetch_array( mysql_query($sql) or die(mysql_error()));
        $this->setQTLopMonBLL($result);
    }
    
    public function getQTLopMonTT($madm_ttlm){
        $sql ="select * from tbl_quatrinhlopmon where madm_ttlm ='".$madm_ttlm."'";
        $result = mysql_query($sql) or die(mysql_error());
        $arr_QTlopmon = array();
        
        while($row = mysql_fetch_array($result)){
            $arr_QTlopmon[] = $this->setQTLopMonBLL($row);
        }
        return $arr_QTlopmon;
    }
    public function getAllQTLopMon(){
          $sql ="select * from tbl_quatrinhlopmon";
        $result = mysql_query($sql) or die(mysql_error());
        $arr_QTlopmon = array();
        
        while($row = mysql_fetch_array($result)){
            $arr_QTlopmon[] = $this->setQTLopMonBLL($row);
        }
        return $arr_QTlopmon;
    }
    
    public function insertQTLopMon($qt_lopmon){
        $sql="INSERT INTO tbl_quatrinhlopmon(
           ma_qtlm
          ,noidungthuchien
          ,thoigianthuchien
          ,ma_cb
          ,ma_lopmon
          ,madm_ttlm
        ) VALUES (
           '".$qt_lopmon->getma_qtlm()."'
          ,'".$qt_lopmon->getnoidungthuchien()."'
          ,'".$qt_lopmon->getthoigianthuchien()."'
          ,'".$qt_lopmon->getma_cb()."'
          ,'".$qt_lopmon->getma_lopmon()."'
          ,'".$qt_lopmon->getmadm_ttlm()."'
        )";
        
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }
    
    public function updateQTLopMon($qt_lopmon){
        $sql="UPDATE tbl_quatrinhlopmon
            SET
              noidungthuchien = '".$qt_lopmon->getnoidungthuchien()."'
              ,thoigianthuchien = '".$qt_lopmon->getthoigianthuchien()."'
              ,ma_cb = '".$qt_lopmon->getma_cb()."'
              ,ma_lopmon = '".$qt_lopmon->getma_lopmon()."'
              ,madm_ttlm = '".$qt_lopmon->getmadm_ttlm()."'
            WHERE ma_qtlm ='".$qt_lopmon->getma_qtlm()."'";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }
    
    public function deleteQTLopMon($ma_qtlm){
        $sql ="delete from tbl_quatrinhlopmon where ma_qtlm ='".$qt_lopmon->getma_qtlm()."'";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }
    
    function setQTLopMonBLL($row){
        $qtlopmon = new QuaTrinhLopMon();
        $qtlopmon->setQTLopMon($row['ma_cb'] ,$row['ma_lopmon'] ,$row['ma_qtlm'] ,$row['madm_ttlm'] ,$row['noidungthuchien'] ,$row['thoigianthuchien']);
        return $qtlopmon;        
    }
    
    
    
 }
 
 
 
 ?>